package com.jiaai.cloud.live.controller;

import com.jiaai.cloud.base.exception.ServiceException;
import com.jiaai.cloud.base.util.RestResultGenerator;
import com.jiaai.cloud.live.service.ITLiveBroadcastService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 直播间 前端控制器
 * </p>
 *
 * @author 佳爱网络科技
 * @version V1.0
 * @title TLiveBroadcastController.java
 * @since 2017/8/1
 */
@RestController
@RequestMapping("api/manage/tLiveBroadcast")
public class TLiveBroadcastController {
    @Autowired
    private ITLiveBroadcastService itLiveBroadcastService;

    //可以根据Id查找,不传id查所有
    @RequestMapping(value = "/findByAll/{anchorId}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public Object findByAll(@PathVariable("anchorId") String anchorId) throws ServiceException {
        try {
            return RestResultGenerator.genSuccessResult(itLiveBroadcastService.findByAnchorId(anchorId));
        } catch (Exception e) {
            throw new ServiceException("查询失敗", e.getMessage());
        }
    }


    @RequestMapping(value = "/selectDataCount" ,method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public Object findCount() throws ServiceException {
        try {
            return RestResultGenerator.genSuccessResult(itLiveBroadcastService.selectDataCount());
        } catch (Exception e) {
            throw new ServiceException("查询失敗", e.getMessage());
        }
    }
}
